Reviewing the Stylebits Parameters
The four parameters of stylebits are AddBit, RemoveBit, AddExtendedBit, RemoveExtendedBit. For a review of these four parameters, and an introduction to Stylebits in general, please read [Stylebits Corner - An Introduction]. For examples of stylebits changing the appearance and input of textboxes, see [Stylebits Corner - Textboxes]. To see Statictext changes with stylebits, see [Stylebits Corner - Statictext]. To see Button changes with stylebits, see [Stylebits Corner - Buttons]. Listbox changes with stylebits were discussed in [Stylebits Corner - Listboxes].
Stylebits, Comboboxes and Borders

A combobox is a combination listbox and textbox. Comboboxes are designed to save space by only showing the listbox when needed. When the arrow button is clicked, the listbox drops down. The user can then mouse click an item from the loaded array. The selected item is then printed in the textbox portion of the combobox. In the standard combobox, it is also possible for the user to type an entry in the textbox that is not already a member of the array. Unlike other controls, comboboxes do not respond well to changes with border stylebits. For this reason, the ExtendedBits aren't all that useful with comboboxes. The stylebits _CBS_LOWERCASE and _CBS_UPPERCASE work quite well with comboboxes. Even though _CBS_SORT is a documented Window's constant, I have never been able to sort a combobox array with the stylebit alone. Fortunately alphabetizing is easily accomplished with Liberty BASIC's native SORT and RELOAD commands. The stylebits that are most effective with comboboxes are _CBS_DROPDOWN, _CBS_DISABLENOSCROLL, _CBS_DROPDOWNLIST, and _CBS_AUTOHSCROLL.
The Listbox and the Textbox

Probably the best way to see combobox stylebits effects are to see them in action. In this demo, six comboboxes are each loaded with the same array. Try mouse clicking and keyboard entry with all of them.
WindowWidth = 400
WindowHeight = 500
UpperLeftX = Int((DisplayWidth - WindowWidth)/2)
UpperLeftY = Int((DisplayHeight - WindowHeight)/3)
Dim month$(12)
For i = 1 to 12
Read m$
month$(i) = m$
Next i
Nomainwin
'Set up a default button
Button #main.default, "", selMonth, UL, -100, -100
'Remove default button from tabstop cycle
Stylebits #main.default, 0, _WS_TABSTOP, 0, 0
'The Standard Combobox
Statictext #main.st1, "Standard", 30, 14, 100, 24
Combobox #main.cb1, month$(), selMonth, 30, 40, 100, 124
'Invisible Combobox; Not very practical.
Statictext #main.st2, "Hidden", 150, 14, 100, 24
Combobox #main.cb2, month$(), selMonth, 150, 40, 100, 124
Stylebits #main.cb2, 0, _WS_VISIBLE, 0, 0
'Listbox stays visible at all times; Textbox accepts user input.
Statictext #main.s3, "Visible Listbox", 270, 14, 100, 24
Combobox #main.cb3, month$(), selMonth, 270, 40, 100, 124
Stylebits #main.cb3, 0, _CBS_DROPDOWN, 0, 0
'Disabled vertical scroll bar when all items are visible
Statictext #main.st4, "Disabled Unneeded Scrollbar", 30, 130, 100, 54
Combobox #main.cb4, month$(), selMonth, 30, 200, 100, 260
Stylebits #main.cb4, _CBS_DISABLENOSCROLL, _CBS_DROPDOWN, 0, 0
'Textbox doesn't accept user input, but instead selects Combobox item
'beginning with pressed character; Mouse clicking Textbox drops Listbox.
Statictext #main.st5, "Keypress Initial", 150, 200, 100, 48
Combobox #main.cb5, month$(), selMonth, 150, 250, 100, 124
Stylebits #main.cb5, _CBS_DROPDOWNLIST, 0, 0, 0
'Limits user input to number of visible characters
Statictext #main.st6, "Limit Number of Characters", 270, 200, 100, 48
Combobox #main.cb6, month$(), selMonth, 270, 250, 80, 124
Stylebits #main.cb6, 0, _CBS_AUTOHSCROLL, 0, 0
Open "Stylebits and the Combobox" for Dialog as #main
#main, "Trapclose [endDemo]"
#main, "Font Times_New_Roman 12 Bold"
#main.cb2, "![Invisible]"
#main.cb1, "Setfocus"
Wait
[endDemo]
Close #main
End
Sub selMonth handle$
If handle$ = "#main.default" Then
#main.cb1, "Contents? m1$"
#main.cb2, "Contents? m2$"
#main.cb3, "Contents? m3$"
#main.cb4, "Contents? m4$"
#main.cb5, "Contents? m5$"
#main.cb6, "Contents? m6$"
month$ = "The Textboxes Contents" + Chr$(13) + _
"Combobox 1: ";m1$ + Chr$(13) + _
"Combobox 2: ";m2$ + Chr$(13) + _
"Combobox 3: ";m3$ + Chr$(13) + _
"Combobox 4: ";m4$ + Chr$(13) + _
"Combobox 5: ";m5$ + Chr$(13) + _
"Combobox 6: ";m6$ + Chr$(13)
Else
#handle$, "Selectionindex? sel"
month$ = month$(sel)
End If
Notice "You chose ";month$
#main.cb5, "Reload"
End Sub
Data "January", "February", "March", "April", "May", "June", "July"
Data "August", "September", "October", "November", "December"
Dialog Windows, Default Buttons and the TabStop Cycle
The advantage of placing comboboxes on a dialog window is the use of the default button. A dialog [window] can have a default button that is activated when the user hits the ENTER key even if that button is not the control with focus. The default button must have the .default extension. In the above demo, the default button is used to read the contents of the textbox portion of each combobox. If you tab from one control to another, you will find that every sixth tab press appears to do nothing. The second combobox is not the culprit. Because it's hidden, that combobox is not receiving focus. It is the default button that lies off the window, but still able to receive focus. The stylebits _WS_TABSTOP as a RemoveBits for the default button removes the button from the tab cycle. The user can now tab through the five comboboxes without skipping a beat.
The Stylebits Corner Series
This installment concludes the discussion of stylebits with specific controls. Future articles will focus on unique stylebits effects discovered and shared by the community. Some snippets include
Eager to try Stylebits with buttons and other window controls? Can't wait for the next newsletter? Good news! The best way to explore and assign stylebit commands is with the Stylebits Wizard option found in Alyce Watson's [Liberty BASIC Workshop].
DEMO
The file stylebitsDemo7.bas is included in the zipped archive of this newsletter.